
"""
概率论5.1
大数定律的更一般形式
"""
import matplotlib.pyplot as plt
import numpy as np
from scipy.stats import binom
from scipy.stats import poisson
from scipy.stats import norm

x = np.arange(1, 10001, 1)
# 二项分布
r1 = binom.rvs(10, 0.6, size=10000)
# 泊松分布
r2 = poisson.rvs(mu=6, size=10000)
# 正态分布
r3 = norm.rvs(loc=6, size=10000)

y = []
rsum = 0.0
for i in range(10000):
    rsum = rsum + (r1[i] + r2[i] + r3[i])
    y.append(rsum / ((i + 1) * 3) - 6)

plt.plot(x, y, color='red')
plt.show()
